package com.jcf.springboot.common.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;

/**
 * @author ${chaofan.ji}
 * @since 2025/4/20
 */
//@Configuration
public class RabbitConfig {
  @Value("${exchange.name}")
  private String exchangeName;
  @Value("${queueA}")
  private String queueA;
  @Value("${queueB}")
  private String queueB;

  @Bean
  public FanoutExchange fanoutExchange(){
    return new FanoutExchange(exchangeName);
  }

  @Bean
  public Queue queueA(){
    return new Queue(queueA);
  }

  @Bean
  public Queue queueB(){
    return new Queue(queueB);
  }

  @Bean
  public Binding bindingA(FanoutExchange fanoutExchange,Queue queueA){
   return BindingBuilder.bind(queueA).to(fanoutExchange);
  }

  @Bean
  public Binding bindingB(FanoutExchange fanoutExchange,Queue queueB){
    return BindingBuilder.bind(queueB).to(fanoutExchange);
  }

}
